﻿using System;
using System.Collections.Generic;
using System.Data;
/*
 * -- Pattern Responsibilities and Restrictions --
 * Definition: An object that acts as a Gateway (466) to a database table. One instance handles all the rows in the table.
 * Table Data Gateway pattern tells very little about how the data container should be modeled. 
 * The challenges of Table Data Gateway is pretty simple, as it only concentrates on 1:1 table/field mapping from code to db.
 * 
 * Data Container:- 
 * May or may not have data container. 
 * DON'T CARE: Data container names should be identical
 * 
 * Data Container Fields:-
 * DON'T CARE: 1 database table column should be mapped to one field of the corresponding data container class
 * DON'T CARE: Extra fields are allowed on any side.
 * DON'T CARE: Field names should be identical
 * DON'T CARE: Foreign key mapping to database fields
 * DON'T CARE: Computation can be implemented on fields (i.e. derived fields) in the class ** primary difference from RowDataGateway **
 * DON'T CARE: Validation logic (i.e. email/phone format etc) on data fields
 * 
 * CRUD Method :-
 * REQUIRED: Data container (if any) and CRUD methods are placed in seperate class. 1 table gateway corresponds to 1 database table.
 * OPTIONAL: Insert/Update method type: instance/static
 * OPTIONAL: Insert/Update method parameter - field as parameter/instance
 * OPTIONAL: Delete/Get method type: instance/static
 * OPTIONAL: Delete/Get method parameter: By Id etc
 * 
 * Business Logic :-
 * REQUIRED: No computational logic (non-field level) can be included in Table Data Gateway class
 * REQUIRED: No transactional/workflow logic can be included in Table Data Gateway class
 * 
*/

namespace TableDataGatewaySample1
{
    public class EmployeeTableDataGateway
    {
        public void Insert(int employeeId, string name, string email, double monthlySalary, int companyId) { }
        public void Update(int employeeId, string name, string email, double monthlySalary, int companyId) { }

        public void Delete(int EmployeeId) { }

        public DataTable GetById(int EmployeeId) { throw new NotImplementedException(); }
        public DataTable GetByCompanyId(int companyId) { throw new NotImplementedException(); }
    }
}

namespace TableDataGatewaySample2
{
    public class Employee
    {
        public int EmployeeId { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public float MonthlySalary { get; set; }
        public int CompanyId { get; set; }

        public Employee() { }
    }

    public class EmployeeTableDataGateway
    {
        public static void Insert(Employee employee) { throw new NotImplementedException(); }
        public static void Update(Employee employee) { throw new NotImplementedException(); }

        public static void Delete(int EmployeeId) { throw new NotImplementedException(); }
        
        public static Employee GetById(int EmployeeId) { throw new NotImplementedException(); }
        public static IList<Employee> GetByCompanyId(int companyId) { throw new NotImplementedException(); }
    }
}
